package com.excesys.exsecs.eco.controller;

import com.excesys.exsecs.common.core.util.R;
import com.excesys.exsecs.eco.service.EcoCoolHourFlowService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * 节能制冷量小时表
 *
 * @author lxc
 * @date 2024-11-26 13:31:09
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/ecoCoolHourFlow")
@Tag(description = "ecoCoolHourFlow", name = "节能制冷量小时表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class EcoCoolHourFlowController {

    private final EcoCoolHourFlowService ecoCoolHourFlowService;

    /**
     * 初始化节能用电量表
     * @return
     */
    @Operation(summary = "初始化节能用电量表" , description = "初始化节能用电量表" )
    @GetMapping("/initPowerHourFlowData" )
    @PreAuthorize("@pms.hasPermission('access_accessDeviceInfo_view')" )
    public R initPowerHourFlowData() {
        ecoCoolHourFlowService.initPowerHourFlowData();
        return R.ok();
    }

    /**
     * 初始化节能制冷量表
     * @return
     */
    @Operation(summary = "初始化节能制冷量表" , description = "初始化节能制冷量表" )
    @GetMapping("/initCoolHourFlowData" )
    @PreAuthorize("@pms.hasPermission('access_accessDeviceInfo_view')" )
    public R initCoolHourFlowData() {
        ecoCoolHourFlowService.initCoolHourFlowData();
        return R.ok();
    }

    @Operation(summary = "查询COP分析详细报表", description = "查询COP分析详细报表")
    @GetMapping("/getCopAnalysisList")
    public R getCopAnalysisList(String startDate, String endDate) {
        if (Objects.isNull(startDate) || Objects.isNull(endDate)) {
            return R.failed("请输入开始时间和结束时间");
        }
        return R.ok(ecoCoolHourFlowService.getCopAnalysisList(startDate, endDate));
    }


}